# Contributor: Magnus Sandin <magnus.sandin@gmail.com>
# Maintainer: Magnus Sandin <magnus.sandin@gmail.com>
pkgname=carla
pkgver=2.5.7
pkgrel=0
pkgdesc="Fully-featured audio plugin host"
url="https://github.com/falkTX/Carla"
options="!check" # No tests available
arch="armv7 aarch64 riscv64 x86 x86_64"
license="GPL-2.0-or-later"
depends="
	python3
	py3-pyliblo
	py3-qt5
	py3-rdflib
	qt5-qtsvg
	$pkgname-plugins-lv2
	$pkgname-plugins-vst2
	"
depends_dev="$pkgname"
makedepends="
	alsa-lib-dev
	file-dev
	fluidsynth-dev
	liblo-dev
	libsndfile-dev
	libx11-dev
	linux-headers
	musl-fts-dev
	pulseaudio-dev
	qt5-qtbase-dev
	qt5-qtsvg-dev
	"
subpackages="$pkgname-dev $pkgname-plugins-vst2 $pkgname-plugins-lv2"
source="$pkgname-$pkgver.tar.gz::https://github.com/falkTX/Carla/archive/refs/tags/v$pkgver.tar.gz
	stats64_2_stats.patch"
builddir="$srcdir/Carla-$pkgver"

build() {
	export CFLAGS="$CFLAGS -O3 -flto=auto"
	export CXXFLAGS="$CXXFLAGS -O3 -flto=auto"
	export LDFLAGS="$LDFLAGS -lfts"

	make features
	make
}

package() {
	make install PREFIX=/usr DESTDIR="$pkgdir"
}

lv2() {
	depends=""
	pkgdesc="$pkgdesc (LV2 plugins)"

	mkdir -p "$subpkgdir/usr/lib/lv2/carla.lv2"
	find "$pkgdir/usr/lib/lv2/carla.lv2" -maxdepth 1 -type f -exec mv {} "$subpkgdir/usr/lib/lv2/carla.lv2" \;
}

vst2() {
	depends=""
	pkgdesc="$pkgdesc (VST2 plugins)"

	mkdir -p "$subpkgdir/usr/lib/vst/carla.vst"
	find "$pkgdir/usr/lib/vst/carla.vst" -maxdepth 1 -type f -exec mv {} "$subpkgdir/usr/lib/vst/carla.vst" \;
}

sha512sums="
c634ade64ff8ab66b0c06b17e33ea6fc758837e19156abbfe214d81fc084d96278bc49cb2941ab7328ed4452bb539cde5afa7f16352b18349ffddd1b53a65f3d  carla-2.5.7.tar.gz
e673f24e79af9869fe4dbddaf4cd503acc31c56022121accddfe59a691db977d1beca46ed090df11d8cca2f021517aaa19e8b2f3901192019dfbc83162bdd793  stats64_2_stats.patch
"
